package com.dynamictpm.notify;


import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * 描述：：
 * <p>
 * ------------------------------------
 *
 * @program: dynamic-tpm
 * @ClassName DefaultSharePublisher
 * @author: it-yml
 * @create: 2023-07-05 16:18
 * @Version 1.0
 * --------------------------------------
 **/
public class DefaultSharePublisher extends DefaultPublisher{

    private final Map<Class<? extends SlowEvent>, Set<Subscriber>> subMappings = new ConcurrentHashMap();

    protected final Set<Subscriber> subscribers = new HashSet<>();

    private final Lock lock = new ReentrantLock();

//    public void addSubscriber(Subscriber subscriber, Class<? extends Event> subscribeType) {
//        Class<? extends SlowEvent> subSlowEventType = (Class<? extends SlowEvent>) subscribeType;
//        subscribers.add(subscriber);
//
//        lock.lock();
//        try {
//            Set<Subscriber> sets = subMappings.get(subSlowEventType);
//            if (sets == null) {
//                Set<Subscriber> newSet = new ConcurrentHashSet();
//                newSet.add(subscriber);
//                subMappings.put(subSlowEventType, newSet);
//                return;
//            }
//            sets.add(subscriber);
//        } finally {
//            lock.unlock();
//        }
//    }
}
